package snsdbook.beans;

import util.SQLUtil;

public class ContentBean {
  private int id_;
  private String user_;
  private String title_;
  private String content_;
  private long timestamp_;
  private String tag_;
  private String parity_;
    
  public ContentBean(int id, int sequence, boolean is_short) {
    id_ = id;
    String id_str = String.valueOf(id);
    String[] ret = SQLUtil.Query(
        "SELECT username " +
        "FROM berita WHERE id_berita = '" +
        id_str + "'");
    user_ = ret[0];
    
    ret = SQLUtil.Query(
        "SELECT judul " +
        "FROM berita WHERE id_berita = '" +
        id_str + "'");
    title_ = ret[0];
    
    ret = SQLUtil.Query(
        "SELECT isi_berita " +
        "FROM berita WHERE id_berita = '" +
        id_str + "'");
    content_ = ret[0];
    
    ret = SQLUtil.Query(
        "SELECT waktu " +
        "FROM berita WHERE id_berita = '" +
        id_str + "'");
    timestamp_ = Long.valueOf(ret[0]);
    
    ret = SQLUtil.Query(
        "SELECT id_tag " +
        "FROM berita WHERE id_berita = '" +
        id_str + "'");
    tag_ = SQLUtil.Query(
        "SELECT nama_tag " +
        "FROM tag WHERE id_tag = '" +
        ret[0] + "'")[0];
    
    if (sequence % 2 == 0) {
      parity_ = "even_content";
    } else {
      parity_ = "odd_content";
    }
  }
  
  public void setId(int id) { id_ = id; }
  
  public void setUser(String user) { user_ = user; }
  
  public void setTitle(String title) { title_ = title; }
  
  public void setTimestamp(long timestamp) { timestamp_ = timestamp; }
  
  public void setContent(String content) { content_ = content; }
  
  public void setTag(String tag) { tag_ = tag; }
  
  public void setParity(String parity) { parity_ = parity; }
  
  public int getId() { return id_; }
  
  public String getUser() { return user_; }
  
  public String getTitle() { return title_; }
  
  public long getTimestamp() { return timestamp_; }
  
  public String getContent() { return content_; }
  
  public String getTag() { return tag_; }
  
  public String getParity() { return parity_; }
}